﻿namespace Bigway.Common.Extensions;

public static class ArrayExtensions
{
    public static void Deconstruct<T>(this T[] array, out T value0, out T value1, out T value2, out T value3, out T value4)
    {
#pragma warning disable CS8601 // Possible null reference assignment.
        value0 = value1 = value2 = value3 = value4 = default;
#pragma warning restore CS8601 // Possible null reference assignment.
        if (array.Length > 0)
        {
            value0 = array[0];
        }

        if (array.Length > 1)
        {
            value1 = array[1];
        }

        if (array.Length > 2)
        {
            value2 = array[2];
        }

        if (array.Length > 3)
        {
            value3 = array[3];
        }

        if (array.Length > 4)
        {
            value4 = array[4];
        }
    }
}